<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="java.sql.*"%> 
<%@ page import="org.liufeng.course.util.*"%> 
<%@ page language="java" import="java.sql.*,java.net.*,java.util.*,java.text.*,java.io.*,java.net.*" %>
<%@ page import="org.liufeng.course.service.RequestService"%> 
<%@ page import="net.sf.json.*"%> 
<%
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String url="jdbc:mysql://sqld.duapp.com:4050/ToszmXBSdefwbBRfZIAt";
 String user="Ec2chH8MHnfQo9cUi0ga6jw9";
 String password="tP94jTsaYQCj8XkRw8nb3QmmYAFp4OX0";

 /*
String url="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8";
String user="root";
String password="niuxiao";
*/

Class.forName("com.mysql.jdbc.Driver");
//获得Connection对象
Connection DBConn = DriverManager.getConnection(url,user,password);
PreparedStatement ps=null;
String id = request.getParameter("id")==null?"":request.getParameter("id").trim();
String sql = "select * from gate where id=?";
ResultSet rs = null;
String cont="";
String name = "1";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>水闸查询</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
	<style>
	ul,li{ margin:0px; padding:0px; list-style:none;}
		.page-aside h1 { color:#404a58; font-size:18px; padding:10px 0px; text-indent:15px; border:1px solid #dfdfe0; border-top:none; border-bottom:none; }
		.page-aside h1.active { color:#fff; }
		.page-aside ul { border:1px solid #dfdfe0; border-top:none; border-bottom:none; }
		.page-aside ul li a{ display:block; color:#6c6d6d; padding:10px 0px; text-indent:15px; background:#fff; border-bottom:1px solid #dfdfe0;  }
		.page-aside ul li a:hover, .page-aside ul li.active a { color:#4482d5; }
	</style>
  </head>
  <body>
  <div class="page-aside">
    <%
try {
	ps = DBConn.prepareStatement(sql);
	ps.setString(1,id);
	rs = ps.executeQuery();
	while(rs.next()){
	String stcd = "7316"; //测站编码
	String sssw = "暂时无数据"; 	//实时水位
	String jjsw = "暂时无数据";// 警戒水位
	String isWarn = "暂时无数据";// 是否超出警戒水位
	String sTime = "暂时无数据";//更新时间
	String dispaly = "none";
	//if(rs.getString("stcd")!=null &&!rs.getString("stcd").equals("null")&&!rs.getString("stcd").equals("")){
	try{
		stcd = "7316";
		String json = RequestService.httpRequest("http://fhs.fxpt.org:8090/HyDroDataService/service/queryZZSpace.action?stcd="+stcd,"utf-8");
		JSONObject ob=JSONObject.fromObject(json);
		JSONArray array=ob.getJSONArray("result");
		JSONObject obnew=array.getJSONObject(0);
		if(!ob.getString("totalCount").equals("0")){
			sssw = StrTools.isStrNull(obnew.get("Z"))+" m";
			jjsw = StrTools.isStrNull(obnew.get("WRZ"))+" m";
			isWarn = StrTools.isStrNull(obnew.get("isWarn")).equals("1")?"是":"否";
			sTime = StrTools.isStrNull(obnew.get("TM"));
			dispaly = "blank";
		}
	}catch(Exception e){
		dispaly = "none";
	}

	cont = "水闸名称: "+rs.getString("gateName")+";\r"+
			"所在堤防："+rs.getString("pondName")+";\r"+
			"所属乡镇："+rs.getString("townCode")+";\r"+
			"水闸规模："+rs.getString("scale")+";\r"+
			"过闸流量："+rs.getString("gateFlow")+"m³/s"+";\r"+
			"闸门净宽："+rs.getString("totalWidth")+";\r"+
			"闸门孔数："+rs.getString("holeNum")+";\r"+
			"闸门型式："+rs.getString("structureType")+";\r"+
			"主要用途："+rs.getString("mainUse")+";\r";
	name = rs.getString("id").trim();
%>



<h1>水闸名称：<%=rs.getString("gateName").trim() %></h1>
  <ul>
  	<li><a>所在堤防：<%=StrTools.isStrNull(rs.getString("pondName")) %></a></li>
  	<li><a>所属乡镇: <%=StrTools.isStrNull(rs.getString("townCode")) %></a></li>
  	<li><a>主管单位：<%=StrTools.isStrNull(rs.getString("manageLevel")) %></a></li>
  	<li><a>水闸规模: <%=StrTools.isStrNull(rs.getString("scale")) %></a></li>
  	<li><a>过闸流量：<%=StrTools.isStrNull(rs.getString("gateFlow")) %>m³/s</a></li>
  	<li><a>闸门净宽：<%=StrTools.isStrNull(rs.getString("totalWidth")) %>m</a></li>
  	<li><a>闸门孔数：<%=StrTools.isStrNull(rs.getString("holeNum")) %></a></li>
  	<li><a>闸门型式：<%=StrTools.isStrNull(rs.getString("structureType")) %></a></li>
  	<li><a>主要用途：<%=StrTools.isStrNull(rs.getString("mainUse")) %></a></li>
	<li style='display:<%=dispaly%>'><a>湖头渡G潮位站数据：</a></li>
	<li style='display:<%=dispaly%>'><a>实时潮位：<%=sssw %></a></li>
	<li style='display:<%=dispaly%>'><a>警戒潮位：<%=jjsw %></a></li>
	<li style='display:<%=dispaly%>'><a>是否超出警戒水位：<%=isWarn %></a></li>
	<li style='display:<%=dispaly%>'><a>获取时间： <%=sTime %></a></li>
  </ul>
				
<%
	}	
} catch (SQLException e) {
	e.printStackTrace();
}finally {
	DBConn.close();
}
cont = URLEncoder.encode(URLEncoder.encode(new String(cont), "utf-8"),"utf-8");
%>
</div>
<a href="<%=basePath%>my.jsp?name=<%=name%>&cont=<%=cont%>" >点击生成二维码</a>
  </body>
</html>
